home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Roger / Roger.jar / Roger$AnimationCanvas$BallsEngine.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-08-31  |  1.9 KB  |  67 lines

  1. import java.util.Random;
  2.  
  3. class Roger$AnimationCanvas$BallsEngine {
  4.    // $FF: renamed from: w int
  5.    int field_0;
  6.    // $FF: renamed from: h int
  7.    int field_1;
  8.    long count;
  9.    Location[] vec;
  10.    Random random;
  11.    // $FF: synthetic field
  12.    private final Roger$AnimationCanvas this$1;
  13.  
  14.    Roger$AnimationCanvas$BallsEngine(Roger$AnimationCanvas this$1) {
  15.       this.this$1 = this$1;
  16.       this.random = new Random();
  17.       this.vec = new Location[4];
  18.    }
  19.  
  20.    void init(int w, int h) {
  21.       this.count = 0L;
  22.       this.field_1 = h;
  23.       this.field_0 = w;
  24.       this.vec[0] = new Location(0, 0);
  25.       this.vec[1] = new Location(10, -20);
  26.       this.vec[2] = new Location(30, -h);
  27.       this.vec[3] = new Location(40, -2 * h / 3);
  28.    }
  29.  
  30.    void tick() {
  31.       ++this.count;
  32.  
  33.       for(int i = 0; i < this.vec.length; ++i) {
  34.          this.vec[i].tick();
  35.       }
  36.  
  37.       for(int i = 0; i < this.vec.length; ++i) {
  38.          if (this.vec[i].y > this.field_1) {
  39.             Location temp = new Location();
  40.  
  41.             do {
  42.                temp.x = Math.abs(this.random.nextInt() % (this.field_0 - 10));
  43.                temp.y = -1 * Math.abs(this.random.nextInt() % (this.field_1 - 10));
  44.             } while(!this.method_0(temp));
  45.  
  46.             this.vec[i] = temp;
  47.          }
  48.       }
  49.  
  50.    }
  51.  
  52.    // $FF: renamed from: ok (Location) boolean
  53.    boolean method_0(Location temp) {
  54.       for(int i = 0; i < this.vec.length; ++i) {
  55.          if ((temp.x < this.vec[i].x && temp.x > this.vec[i].x - 10 || temp.x > this.vec[i].x && temp.x < this.vec[i].x + 10) && (temp.y < this.vec[i].y && temp.y > this.vec[i].y - 10 || temp.y > this.vec[i].y && temp.y < this.vec[i].y + 10)) {
  56.             return false;
  57.          }
  58.       }
  59.  
  60.       return true;
  61.    }
  62.  
  63.    Location[] getLocations() {
  64.       return this.vec;
  65.    }
  66. }
  67.